Skip to content

Add test for cv synchronous-distribution delete#22006

Open
sambible wants to merge 4 commits into
SatelliteQE:masterfrom
sambible:cv-synchronous-distribution-delete
Open

Add test for cv synchronous-distribution delete#22006
sambible wants to merge 4 commits into
SatelliteQE:masterfrom
sambible:cv-synchronous-distribution-delete

Conversation

@sambible

@sambible sambible commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Problem Statement

In previous versions of Foreman, actions that used the pulp task DeleteDistributions weren't planned as an asynchronous pulp task, and this caused potential race conditions.

Solution

This is a difficult issue to reliably reproduce, so verifying it via checking the Dynflow console is the most reliable way to verify.

Related Issues

https://redhat.atlassian.net/browse/SAT-45529

PRT test Cases example

trigger: test-robottelo
pytest: tests/foreman/api/test_contentview.py -k 'test_positive_synchronous_distribution_delete'

Summary by Sourcery

Tests:

  • Add API test validating synchronous distribution delete for content views using a synced Red Hat repository and Dynflow task output inspection.

@sambible sambible self-assigned this Jun 30, 2026
@sambible sambible requested a review from a team as a code owner June 30, 2026 13:32
@sambible sambible added No-CherryPick PR doesnt need CherryPick to previous branches Stream Introduced in or relating directly to Satellite Stream/Master labels Jun 30, 2026
@sourcery-ai

sourcery-ai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds a high-level API test that validates synchronous distribution deletion for content views, ensuring the associated Pulp DeleteDistributions task is created and contains expected output.

File-Level Changes

Change Details Files
Add API test verifying DeleteDistributions dynflow task output when deleting a content view with a synced repository.
  • Import robottelo constants module to access product and repository identifiers.
  • Create and sync a Red Hat repository via api_factory and Repository API.
  • Associate synced repository with a content view, publish it, and ensure a single version and repository exist.
  • Remove the content view from the Library environment and delete the content view to trigger the Dynflow task.
  • Wait for the related RemoveFromEnvironment Dynflow task via wait_for_tasks using a specific search query.
  • Execute a foreman-rake console command to locate the DeleteDistributions Pulp3 task in the execution plan and fetch its output.
  • Assert the Pulp task output is non-empty by checking for expected state and task name strings in stdout.
tests/foreman/api/test_contentview.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The wait_for_tasks search query is tightly coupled to the exact human-readable action description (name, org, etc.), which may change and make the test flaky; consider searching by more stable attributes (e.g., task label and resource IDs) or capturing the specific task ID from the delete operation instead.
  • The long inline foreman-rake console command string in the test is somewhat brittle and hard to read; extracting this into a reusable helper that takes the task ID and returns the DeleteDistributions output would improve readability and make future changes easier.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `wait_for_tasks` search query is tightly coupled to the exact human-readable action description (name, org, etc.), which may change and make the test flaky; consider searching by more stable attributes (e.g., task label and resource IDs) or capturing the specific task ID from the delete operation instead.
- The long inline `foreman-rake console` command string in the test is somewhat brittle and hard to read; extracting this into a reusable helper that takes the task ID and returns the DeleteDistributions output would improve readability and make future changes easier.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@vijaysawant

Copy link
Copy Markdown
Contributor

Solution

This is a difficult issue to reliably reproduce, so verifying it via checking the Dynflow console is the most reliable way to verify.

using postgres psql, couldn't decode the binary output which is in Ruby Marshal format, a simpler approach using foreman-rake console gives a better output. I am taking referenec for RefreshDistribution action.

@vijaysawant vijaysawant left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting for PRT to get green.
Ack 👏

@sambible

Copy link
Copy Markdown
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_contentview.py -k 'test_positive_synchronous_distribution_delete'

@sambible

sambible commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author
trigger: test-robottelo
pytest: tests/foreman/api/test_contentview.py -k 'test_positive_synchronous_distribution_delete'

@Satellite-QE

Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 15992
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_contentview.py -k test_positive_synchronous_distribution_delete --external-logging
Test Result : ========== 1 passed, 101 deselected, 6 warnings in 978.36s (0:16:18) ===========

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Jul 1, 2026

@vsedmik vsedmik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me, left a few proposals

Comment thread tests/foreman/api/test_contentview.py Outdated
Comment thread tests/foreman/api/test_contentview.py Outdated
Comment thread tests/foreman/api/test_contentview.py Outdated
Comment thread tests/foreman/api/test_contentview.py Outdated
@Satellite-QE Satellite-QE removed the PRT-Passed Indicates that latest PRT run is passed for the PR label Jul 7, 2026
@sambible sambible force-pushed the cv-synchronous-distribution-delete branch from eca70d4 to 9b1e8aa Compare July 7, 2026 17:38
@sambible sambible requested a review from vsedmik July 7, 2026 17:39
@sambible

sambible commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author
trigger: test-robottelo
pytest: tests/foreman/api/test_contentview.py -k 'test_positive_synchronous_distribution_delete'

@Satellite-QE

Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 16059
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_contentview.py -k test_positive_synchronous_distribution_delete --external-logging
Test Result : ========== 1 passed, 102 deselected, 6 warnings in 1172.23s (0:19:32) ==========

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No-CherryPick PR doesnt need CherryPick to previous branches PRT-Passed Indicates that latest PRT run is passed for the PR Stream Introduced in or relating directly to Satellite Stream/Master

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants